import requests

url = 'http://localhost:11434/api/generate'
data = {
    'prompt': '你是谁？',
    'model': 'llama3.2',
    'stream': False
}

resp = requests.post(url, json=data)
print(resp.text)

url = 'http://localhost:11434/api/chat'
data = {
    "messages": [
        {
            "role": "system",
            "content": "You are a warm-hearted assistant, and you only speak Chinese."
        },
        {
            "role": "user",
            "content": "李华去公园玩把腿摔断了，被送到医院了。腿摔断一般要多长时间好？"
        },
        {
            "role": "assistant",
            "content": "腿摔断的恢复时间不一，通常需要几个月才能基本康复。\n\n如果是轻微的骨折，一般可以在1-2个月内恢复，主要需要注意休息和康复锻炼。"
        },
        {
            "role": "user",
            "content": "李华为啥去医院了？"
        }
    ],
    'model': 'llama3.2',
    'stream': False
}

resp = requests.post(url, json=data)
print(resp.text)
